package com.njtoyo.taxi.admin.rest.controller.data;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.njtoyo.taxi.admin.aop.PermissionScope;
import com.njtoyo.taxi.admin.rest.presenter.data.allowance.*;
import com.njtoyo.taxi.admin.rest.wrapper.data.allowance.AllowanceChartWrapper;
import com.njtoyo.taxi.admin.rest.wrapper.data.allowance.AllowanceWrapper;
import com.njtoyo.taxi.admin.service.data.AllowanceCustomerService;
import com.njtoyo.taxi.entity.backend.AdminUser;
import com.taxi.entity.common.RestResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;

import javax.validation.Valid;
import java.util.List;

@RequestMapping("/data/allowance/customer")
@Api(value = "乘客补贴", tags = "补贴统计-乘客")
@RestController
public class AllowanceCustomerController {

    @Autowired
    @Qualifier("AllowanceCustomerServiceCacheImpl")
    private AllowanceCustomerService allowanceCustomerService;

    @GetMapping()
    @ApiOperation(value = "乘客补贴", notes = "权限：allowance")
    @ApiOperationSupport(order = 1)
    @PermissionScope(names = {"allowance"})
    public RestResult<CustomerProportionPresenter> proportion(@ApiIgnore @ModelAttribute("admin") AdminUser adminUser, @Valid AllowanceWrapper wrapper) {
        return allowanceCustomerService.proportion(adminUser, wrapper);
    }

    @GetMapping("/coupon")
    @ApiOperation(value = "乘客优惠券补贴", notes = "权限：allowance")
    @ApiOperationSupport(order = 2)
    @PermissionScope(names = {"allowance"})
    public RestResult<CustomerCouponPresenter> coupon(@ApiIgnore @ModelAttribute("admin") AdminUser adminUser, @Valid AllowanceWrapper wrapper) {
        return allowanceCustomerService.coupon(adminUser, wrapper);
    }

    @GetMapping("/wechat")
    @ApiOperation(value = "乘客小程序红包", notes = "权限：allowance")
    @ApiOperationSupport(order = 3)
    @PermissionScope(names = {"allowance"})
    public RestResult<CustomerWechatPresenter> wechat(@ApiIgnore @ModelAttribute("admin") AdminUser adminUser, @Valid AllowanceWrapper wrapper) {
        return allowanceCustomerService.wechat(adminUser, wrapper);
    }

    @GetMapping("/wave")
    @ApiOperation(value = "乘客波浪补贴", notes = "权限：allowance")
    @ApiOperationSupport(order = 4)
    @PermissionScope(names = {"allowance"})
    public RestResult<CustomerWavePresenter> wave(@ApiIgnore @ModelAttribute("admin") AdminUser adminUser, @Valid AllowanceWrapper wrapper) {
        return allowanceCustomerService.wave(adminUser, wrapper);
    }

    @GetMapping("/balance")
    @ApiOperation(value = "乘客余额", notes = "权限：allowance")
    @ApiOperationSupport(order = 5)
    @PermissionScope(names = {"allowance"})
    public RestResult<CustomerBalancePresenter> balance(@ApiIgnore @ModelAttribute("admin") AdminUser adminUser, @Valid AllowanceWrapper wrapper) {
        return allowanceCustomerService.balance(adminUser, wrapper);
    }

    @GetMapping("/coupon/chart")
    @ApiOperation(value = "乘客优惠券补贴趋势图", notes = "权限：allowance")
    @ApiOperationSupport(order = 6)
    @PermissionScope(names = {"allowance"})
    public RestResult<List<CustomerCouponChartPresenter>> couponChart(@ApiIgnore @ModelAttribute("admin") AdminUser adminUser, @Valid AllowanceChartWrapper wrapper) {
        return allowanceCustomerService.couponChart(adminUser, wrapper);
    }

    @GetMapping("/wave/chart")
    @ApiOperation(value = "乘客波浪补贴趋势图", notes = "权限：allowance")
    @ApiOperationSupport(order = 7)
    @PermissionScope(names = {"allowance"})
    public RestResult<List<CustomerWaveChartPresenter>> waveChart(@ApiIgnore @ModelAttribute("admin") AdminUser adminUser, @Valid AllowanceChartWrapper wrapper) {
        return allowanceCustomerService.waveChart(adminUser, wrapper);
    }

    @GetMapping("/balance/chart")
    @ApiOperation(value = "乘客余额趋势图", notes = "权限：allowance")
    @ApiOperationSupport(order = 7)
    @PermissionScope(names = {"allowance"})
    public RestResult<List<CustomerBalanceChartPresenter>> balanceChart(@ApiIgnore @ModelAttribute("admin") AdminUser adminUser, @Valid AllowanceChartWrapper wrapper) {
        return allowanceCustomerService.balanceChart(adminUser, wrapper);
    }

    @GetMapping("/chart")
    @ApiOperation(value = "乘客补贴趋势图", notes = "权限：allowance")
    @ApiOperationSupport(order = 8)
    @PermissionScope(names = {"allowance"})
    public RestResult<List<CustomerProportionChartPresenter>> proportion(@ApiIgnore @ModelAttribute("admin") AdminUser adminUser, @Valid AllowanceChartWrapper wrapper) {
        return allowanceCustomerService.proportionChart(adminUser, wrapper);
    }
}
